package com.vishop.models;

import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

@Entity
public class Categorie {
	@Id	@GeneratedValue(strategy=GenerationType.AUTO)
	private int categorieId;
	private String naam;
	@OneToMany(cascade=CascadeType.PERSIST)
	@JoinTable(name="CategorieProducten", joinColumns=@JoinColumn(name="categorieId"),
			inverseJoinColumns=@JoinColumn(name="productId"))
	@GenericGenerator(name="hilo-gen", strategy="hilo")
	@CollectionId(columns = { @Column(name="categorieProductenId") }, generator = "hilo-gen", type = @Type(type="long"))
	private Collection<Product> product = new ArrayList<Product>();
	
	//constructor
	public Categorie(){
		
	}
	
	public Categorie(int categorieId, String naam, Collection<Product> product){
		super();
		this.categorieId = categorieId;
		this.naam = naam;
		this.product = product;
	}
	@Override
	public String toString() {
		return naam;
	}
	//getters en setters
	public Collection<Product> getProduct() {
		return product;
	}
	public void setProduct(Collection<Product> product) {
		this.product = product;
	}
	public int getCategorieId() {
		return categorieId;
	}
	public void setCategorieId(int categorieId) {
		this.categorieId = categorieId;
	}
	public String getNaam() {
		return naam;
	}
	public void setNaam(String naam) {
		this.naam = naam;
	}

}
